wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
return false;
}
-
+ // Revision title doesn't match the page title given?
if ( $this->mPage->getID() != $revision->getPage() ) {
- $data = $this->mPage->pageDataFromId( wfGetDB( DB_SLAVE ), $revision->getPage() );
-
- if ( !$data ) {
+ $function = array( get_class( $this->mPage ), 'newFromID' );
+ $this->mPage = call_user_func( $function, $revision->getPage() );
+ if ( !$this->mPage->getId() ) {
wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" );
return false;
}
-
- $title = Title::makeTitle( $data->page_namespace, $data->page_title );
- $this->mPage = new WikiPage( $title );
- $this->mPage->loadPageData( $data );
}
} else {
if ( $this->mPage->getLatest() === false ) {
global $wgOut;
$this->mParserOutput = $this->getOutputFromWikitext( $text, $cache, $parserOptions );
+
+ $this->doCascadeProtectionUpdates( $this->mParserOutput );
+
$wgOut->addParserOutput( $this->mParserOutput );
}
+ /**
+ * Lightweight method to get the parser output for a page, checking the parser cache
+ * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
+ * consider, so it's not appropriate to use there.
+ *
+ * @since 1.16 (r52326) for LiquidThreads
+ *
+ * @param $oldid mixed integer Revision ID or null
+ * @param $user User The relevant user
+ * @return ParserOutput or false if the given revsion ID is not found
+ */
+ public function getParserOutput( $oldid = null, User $user = null ) {
+ global $wgEnableParserCache, $wgUser;
+ $user = is_null( $user ) ? $wgUser : $user;
+
+ // Should the parser cache be used?
+ $useParserCache = $wgEnableParserCache &&
+ $user->getStubThreshold() == 0 &&
+ $this->mPage->exists() &&
+ $oldid === null;
+
+ wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
+
+ if ( $user->getStubThreshold() ) {
+ wfIncrStats( 'pcache_miss_stub' );
+ }
+
+ if ( $useParserCache ) {
+ $parserOutput = ParserCache::singleton()->get( $this, $this->mPage->getParserOptions() );
+ if ( $parserOutput !== false ) {
+ return $parserOutput;
+ }
+ }
+
+ // Cache miss; parse and output it.
+ if ( $oldid === null ) {
+ $text = $this->mPage->getRawText();
+ } else {
+ $rev = Revision::newFromTitle( $this->getTitle(), $oldid );
+ if ( $rev === null ) {
+ return false;
+ }
+ $text = $rev->getText();
+ }
+
+ return $this->getOutputFromWikitext( $text, $useParserCache );
+ }
+
/**
* This does all the heavy lifting for outputWikitext, except it returns the parser
* output instead of sending it straight to $wgOut. Makes things nice and simple for,
* @param $title Title object
* @return mixed Database result resource, or false on failure
*/
- protected function pageDataFromTitle( $dbr, $title ) {
+ public function pageDataFromTitle( $dbr, $title ) {
return $this->pageData( $dbr, array(
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey() ) );
* @param $id Integer
* @return mixed Database result resource, or false on failure
*/
- protected function pageDataFromId( $dbr, $id ) {
+ public function pageDataFromId( $dbr, $id ) {
return $this->pageData( $dbr, array( 'page_id' => $id ) );
}
}
}
- /**
- * Lightweight method to get the parser output for a page, checking the parser cache
- * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
- * consider, so it's not appropriate to use there.
- *
- * @since 1.16 (r52326) for LiquidThreads
- *
- * @param $oldid mixed integer Revision ID or null
- * @param $user User The relevant user
- * @return ParserOutput or false if the given revsion ID is not found
- */
- public function getParserOutput( $oldid = null, User $user = null ) {
- global $wgEnableParserCache, $wgUser;
- $user = is_null( $user ) ? $wgUser : $user;
-
- // Should the parser cache be used?
- $useParserCache = $wgEnableParserCache &&
- $user->getStubThreshold() == 0 &&
- $this->exists() &&
- $oldid === null;
-
- wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
-
- if ( $user->getStubThreshold() ) {
- wfIncrStats( 'pcache_miss_stub' );
- }
-
- if ( $useParserCache ) {
- $parserOutput = ParserCache::singleton()->get( $this, $this->getParserOptions() );
- if ( $parserOutput !== false ) {
- return $parserOutput;
- }
- }
-
- // Cache miss; parse and output it.
- if ( $oldid === null ) {
- $text = $this->getRawText();
- } else {
- $rev = Revision::newFromTitle( $this->getTitle(), $oldid );
- if ( $rev === null ) {
- return false;
- }
- $text = $rev->getText();
- }
-
- return $this->getOutputFromWikitext( $text, $useParserCache );
- }
-
/*
* @deprecated since 1.19
*/